package algotithm.acwing.greedy.test913;

import java.io.*;
import java.util.Arrays;

/**
 * @author zhouyanxiang
 * @Date 2021-01-2021/1/31-15:17
 */
public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));

        int n = Integer.parseInt(reader.readLine());
        String[] num = reader.readLine().split(" ");
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = Integer.parseInt(num[i]);
        }

        Arrays.sort(arr);
        long res = 0;
        for (int i = 0; i < n; i++) {
            res += arr[i] * (n-i-1);
        }
        writer.write(res + "\n");
        writer.flush();
        writer.close();
        reader.close();
    }

}
